home *** CD-ROM | disk | FTP | other *** search
- /*
- ** MCPP.trans: Konvertiert Aztec (5.2) Fehlerdateien für MegaEd
- ** von M-J, 100% PD
- */
-
- #include <exec/memory.h>
- #include <dos/dos.h>
- #include <dos/dostags.h>
- #include <string.h>
-
- void main(void)
- {
- const char *file1="T:MegaEdMake-ErrFile";
- const char *file2="T:MegaEdMake-Errors";
- BPTR con;
- BPTR fileh;
- char *old=NULL,*new=NULL;
- char *off, *off2, *dest, *warn, *last;
- LONG len;
- short i;
- BOOL errors=FALSE;
- //MCPP Datei lesen
- if(!(fileh=Open(file1,MODE_OLDFILE))) return;
- Seek(fileh,0,OFFSET_END);
- len=Seek(fileh,0,OFFSET_BEGINNING);
- if(len)
- {
- if(!(old=(char*)AllocVec(len+1,MEMF_PUBLIC)))
- {Close(fileh); return;}
- if(Read(fileh,old,len)!=len)
- {FreeVec(old); Close(fileh); return;}
- }
- Close(fileh);
- if(!len) return;
- old[len]=0;
- // Konvertierung
- if(!(new=(char*)AllocVec(len+1,MEMF_PUBLIC))) return;
-
- off=old;
- dest=new;
- for(i=0;i<2;i++) // 2 Zeilen überlesen
- {
- if(!(off=strchr(off,10))) goto esc;
- off++;
- }
- for(;;)
- {
- off=strstr(off,"ERROR ");
- off2=strstr(off,"WARN");
- if(!off && !off2) break;
- if(!off || (off2 && (ULONG)off2 < (ULONG)off))
- {off=off2; *dest='W';}
- else *dest='E';
- dest++;
- if((off2=strchr(off,10))) *off2=0;
- off2=off;
-
- off-=3;
- for(;isdigit(*(off-1));) off--;
- for(;isdigit(*off);off++,dest++) *dest=*off;
- *dest='/'; dest++;
- *dest='1'; dest++;
- *dest=10; dest++;
- // Text
- strcpy(dest,off2);
- off+=strlen(off)+1;
- dest+=strlen(dest);
- *dest=10;
- dest++;
- errors=TRUE;
- last=dest;
-
- if(!*off) break;
- }
- esc:
- if(errors)
- {
- if(fileh=Open(file2,MODE_NEWFILE))
- {
- len=(LONG)last-(LONG)new;
- Write(fileh,new,len);
- Close(fileh);
- }
- }
- else DeleteFile(file2);
- if(old) FreeVec(old);
- if(new) FreeVec(new);
- }
-
-